package com.ouyeel.wlxer.base;

import android.app.Activity;
import android.app.Dialog;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.Gravity;

import com.ouyeel.wlxer.widget.MyDiglog;
import com.ouyeel.wlxer.widget.MyToast;
import com.xys.libzxing.zxing.utils.ViewUtil;

import butterknife.ButterKnife;

/**
 * Created by rankaifeng on 2017/9/25.
 */

public abstract class BaseAppStar extends Activity {
    Dialog progressDlg;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ViewUtil.initSystemBar(this, Color.parseColor("#00000000"));
        setContentView(getLayout());
        ButterKnife.bind(this);
        initView();
    }


    public abstract int getLayout();

    public abstract void initView();


    /**
     * 显示加载进度框
     *
     * @param msg
     */
    public void showProgress(String msg) {
        progressDlg = MyDiglog.createLoadingDialog(BaseAppStar.this, msg, false);
    }

    /**
     * 隐藏进度框
     */
    public void hideProgress() {
        if (progressDlg != null && progressDlg.isShowing()) {
            progressDlg.dismiss();
        }
    }

    /**
     * 显示tost
     *
     * @param msg
     */
    public void showTost(String msg) {
        MyToast myToast = MyToast.makeText(BaseAppStar.this, msg);
        myToast.setGravity(Gravity.CENTER, 0, 0);
        myToast.show();
    }
}
